# encoding=utf-8
import sys
from GeneralFunction.Operation import operation
reload(sys)
sys.setdefaultencoding('utf-8')
from GeneralService import Login
from time import sleep
from Configure import Attribute
class babyinfo(Login.BaseLogin):
    def test_updateMyInfo(self):
        '''换头像---包含处理popuwindow'''
        self.login()
        dr=self.driver
        dr.find_element_by_id(Attribute.bottom_mine_id).click()
        dr.find_element_by_id(Attribute.babyinfo_babyInfo_id).click()
        dr.find_element_by_id(Attribute.babyinfo_mineHead_id).click()
        xyInfo=operation.getCurrentElementXY(dr,"android.view.View")
        xInfo=xyInfo["xForPhone"]/2#x坐标获取中间位置
        yInfo=xyInfo["yForPhone"]-200#Y坐标最大值是最下面，所以减去一定数值就是从下向上的
        dr.tap([(xInfo,yInfo)],50)
        dr.find_element_by_id(Attribute.babyinfo_takePhoto_id).click()
        sleep(1)
        dr.find_element_by_id(Attribute.babyinfo_takePhotoOK_id).click()
        sleep(1)
        print(dr.current_activity)
        #WebDriverWait(dr,20).until(dr.find_element_by_id(Attribute.babyinfo_takePhotoFinsh_id))
        dr.find_element_by_id(Attribute.babyinfo_takePhotoFinsh_id).click()
        sleep(1)
        if dr.current_activity!='com.shenzhou.lbt_jz.activity.sub.lbt.PersonalInfoActivity':
            dr.find_element_by_id(Attribute.babyinfo_takePhotoFinsh_id).click()